package com.hdyg.sixg.adapter;

import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hdyg.sixg.R;
import com.hdyg.sixg.entry.MiniBean;
import com.hdyg.sixg.util.ImageLoadUtil;
import java.util.List;

/**
 * @author CZB
 * @describe 我的矿机适配器
 * @time 2019/3/20 14:22
 */
public class MyMiniAdapter extends BaseQuickAdapter<MiniBean.ListBean, BaseViewHolder> {
    public MyMiniAdapter(int layoutResId, @Nullable List<MiniBean.ListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MiniBean.ListBean item) {
        ImageLoadUtil.imageLoad(mContext,item.getPic(),helper.getView(R.id.iv_mini));
        String top = String.format(mContext.getResources().getString(R.string.mini_machine_type),item.getSize());
        String bottom = String.format(mContext.getResources().getString(R.string.mini_machine_amount),item.getAmount());
        helper.setText(R.id.tv_left_top,top);
        helper.setText(R.id.tv_left_bottom,bottom);
        helper.setText(R.id.tv_right_top,item.getStatus());
        if ("1".equals(item.getState())){
            //工作中
            helper.setTextColor(R.id.tv_right_top,mContext.getResources().getColor(R.color.main_color));
        }else if ("2".equals(item.getState())){
            //已结束
            helper.setTextColor(R.id.tv_right_top,mContext.getResources().getColor(R.color.gray_80));
        }
    }
}
